<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<head>
    <meta charset="utf-8" />
    <title th:text="${sysConfig.get('title')+' | 登录页'}"></title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />

    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />
    <link href="/assets/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <link href="/assets/plugins/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
    <link href="/assets/plugins/font-awesome/5.0/css/fontawesome-all.min.css" rel="stylesheet" />
    <link href="/assets/plugins/animate/animate.min.css" rel="stylesheet" />
    <link href="/assets/css/default/style.min.css" rel="stylesheet" />
    <link href="/assets/css/default/style-responsive.min.css" rel="stylesheet" />
    <link href="/assets/css/default/theme/default.css" rel="stylesheet" id="theme" />
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== BEGIN PAGE LEVEL STYLE ================== -->
    <link href="/assets/plugins/parsley/src/parsley.css" rel="stylesheet" />
    <!-- ================== END PAGE LEVEL STYLE ================== -->

    <!-- ================== BEGIN BASE JS ================== -->
    <script src="/assets/plugins/pace/pace.min.js"></script>
    <!-- ================== END BASE JS ================== -->
</head>
<body class="pace-top bg-white">
<!-- begin #page-loader -->
<div id="page-loader" class="fade show"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade">
    <!-- begin login -->
    <div class="login login-with-news-feed">
        <!-- begin news-feed -->
        <div class="news-feed">
            <div class="news-image" style="background-image: url(/assets/img/login-bg/login-bg-11.jpg)"></div>
            <div class="news-caption">
                <h4 class="caption-title"><b>都市宝</b> 应用App</h4>
                <p>
                    都市宝支持的APP有 iPhone®, iPad®, and Android™. 各大应用市场可以下载.
                </p>
            </div>
        </div>
        <!-- end news-feed -->
        <!-- begin right-content -->
        <div class="right-content">
            <!-- begin login-header -->
            <div class="login-header">
                <div class="brand">
                    <span class="logo"></span> <b>都市宝</b>
                    <small>都市宝生活服务购物平台</small>
                </div>
                <div class="icon">
                    <i class="fa fa-sign-in"></i>
                </div>
            </div>
            <!-- end login-header -->
            <!-- begin login-content -->
            <div class="login-content">
                <form action="index.html" method="GET" class="margin-bottom-0" id="theForm" >
                    <div class="form-group m-b-15">
                        <input type="text" class="form-control form-control-lg" placeholder="输入用户" id="userName" data-parsley-required="true" data-parsley-length="[2, 100]"/>
                    </div>
                    <div class="form-group m-b-15">
                        <input type="password" class="form-control form-control-lg" placeholder="输入密码" id="password" data-parsley-required="true" data-parsley-length="[2, 100]" />
                    </div>

                    <div class="form-group m-b-15">
                        <input type="text" class="form-control form-control-lg" placeholder="输入验证码" id="code" data-parsley-required="true" data-parsley-length="[4, 4]" data-parsley-error-message="验证码长度为4."/>
                    </div>

                    <div class="form-group m-b-15">
                        <img src="/admin/getCode" onclick="this.src='/admin/getCode?t='+new Date().getTime()" />
                    </div>


                    <div class="checkbox checkbox-css m-b-30">
                        <input type="checkbox" id="rememberMe" value="" />
                        <label for="rememberMe">
                            记住我
                        </label>
                    </div>
                    <div class="login-buttons">
                        <button type="submit" class="btn btn-success btn-block btn-lg">登录</button>
                    </div>
                    <div class="m-t-20 m-b-40 p-b-40 text-inverse">
                        还没有账号? 点击 <a href="register_v3.html" class="text-success">这里</a> 去注册.
                    </div>
                    <hr />
                    <p class="text-center text-grey-darker">
                        &copy; Color Admin All Right Reserved 2018
                    </p>
                </form>
            </div>
            <!-- end login-content -->
        </div>
        <!-- end right-container -->
    </div>
    <!-- end login -->

    <!-- begin theme-panel -->
    <div th:replace="/common/theme :: theme">

    </div>
    <!-- end theme-panel -->
</div>
<!-- end page container -->

<!-- ================== BEGIN BASE JS ================== -->
<script src="/assets/plugins/jquery/jquery-3.2.1.min.js"></script>
<script src="/assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<script src="/assets/plugins/bootstrap/4.1.0/js/bootstrap.bundle.min.js"></script>
<!--[if lt IE 9]>
<script src="/assets/crossbrowserjs/html5shiv.js"></script>
<script src="/assets/crossbrowserjs/respond.min.js"></script>
<script src="/assets/crossbrowserjs/excanvas.min.js"></script>
<![endif]-->
<script src="/assets/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/assets/plugins/js-cookie/js.cookie.js"></script>
<script src="/assets/js/theme/default.min.js"></script>
<script src="/assets/js/apps.min.js"></script>
<!-- ================== END BASE JS ================== -->

<script src="/assets/plugins/parsley/dist/parsley.js"></script>
<script src="/assets/plugins/parsley/dist/i18n/zh_cn.js"></script>
<script src="/assets/plugins/bootstrap-sweetalert/sweetalert.min.js"></script>

<script>
    $(document).ready(function() {
        App.init();

        $('#theForm').parsley().on('form:submit', function() {
            let ok = $('.parsley-error').length === 0;
            let userName = $('#userName').val()
            let password = $('#password').val()
            let code = $('#code').val()
            let rememberMe = $('#rememberMe').prop('checked')

            if(ok){ // 代表校验通过
                //执行登录操作

                $.get(
                    "/admin/doLogin",
                    { 'userName': userName, 'password': password,'code':code,'rememberMe':rememberMe },
                    function(ret){
                        if(ret === true){//执行跳转
                            window.location.href='/admin/list?op=setting&opc=admin_list'
                        }else{
                            swal({
                                title: '登录异常?',
                                text: '验证码或者账号密码不正确!',
                                icon: 'error',
                                buttons: {
                                    confirm: {
                                        text: '关闭',
                                        value: true,
                                        visible: true,
                                        className: 'btn btn-danger',
                                        closeModal: true
                                    }
                                }
                            });
                        }
                    }
               );


            }

            return false; // 禁止提交表单
        });

    });
</script>
</body>
</html>
